package com.flexoop.lib.components.arraycollection {

	import org.flexunit.Assert;

	public class PagedArrayCollectionTest {
		
		private var _acPagedArrayCollection:PagedArrayCollection;
		private var _tempArray:Array;

		public function PagedArrayCollectionTest() {
		}
		
		[Before]
		public function setUp():void {
			_tempArray = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 ];
			_acPagedArrayCollection = new PagedArrayCollection( _tempArray );
		}
		
		[Test]
		public function testTotalPages():void {
			Assert.assertEquals( "validate that totalPages is set correctly initially", 2, _acPagedArrayCollection.totalPages );
			_acPagedArrayCollection.source = _tempArray.concat( _tempArray );
			Assert.assertEquals( "validate that totalpages changes after source change", 3, _acPagedArrayCollection.totalPages );
		}
		
		[Test]
		public function testCurrentPage():void {
			Assert.assertEquals( "validate that current page is set to 1", 1, _acPagedArrayCollection.currentPage );
		}
		
		[Test]
		public function testNext():void {
			_acPagedArrayCollection.next();
			Assert.assertEquals( "validate that next moves to next page", 2, _acPagedArrayCollection.currentPage );
		}
		
		[Test]
		public function testLast():void {
			_acPagedArrayCollection.source = _tempArray.concat( _tempArray ); // make array larger
			_acPagedArrayCollection.last();
			Assert.assertEquals( "validate that last moves to last page", 3, _acPagedArrayCollection.currentPage );
		}
		
		[After]
		public function tearDown():void {
			_acPagedArrayCollection = null;
		}

	}
}